<template>
  <div class="box">
    <div
      class="list"
      v-for="item in list.list"
      :key="item.id"
      @click="skip(item.id)"
    >
      <img :src="item.picUrl" />
      <i>{{ item.name }}</i>
      <i id="price">¥&nbsp;{{ item.retailPrice }}</i>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
defineProps(['list'])
const skip = (id) => {
  router.push({
    name: 'detail',
    params: { id }
  })
}
</script>

<style scoped>
.box {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
img {
  width: 80%;
}
#price {
  color: rgb(228, 194, 0);
}
</style>
